#include <iomanip>
#include "value.hpp"

namespace etcd {

Value::Value()
    : dir(false),
      created(0),
      modified(0),
      _ttl(0),
      leaseId(0) {
}

Value::Value(etcdv3::KeyValue const& kv) {
    dir = false;
    _key = kv.kvs.key();
    value = kv.kvs.value();
    created = kv.kvs.create_revision();
    modified = kv.kvs.mod_revision();
    leaseId = kv.kvs.lease();
    _ttl = kv.get_ttl();
}

std::string const& Value::key() const {
    return _key;
}

bool Value::is_dir() const {
    return dir;
}

std::string const& Value::as_string() const {
    return value;
}

int Value::created_index() const {
    return created;
}

int Value::modified_index() const {
    return modified;
}

int Value::ttl() const {
    return _ttl;
}

int64_t Value::lease() const {
    return leaseId;
}

}
